<ui:composition xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" 
	xmlns:p="http://primefaces.prime.com.tr/ui" template="template/template.xhtml">
	<ui:define name="title">
		<h:outputText value="#{msgs.activityDocumentation}"/>
	</ui:define>
	<ui:define name="bodyInclude">
		<ui:include src="include/menu.xhtml" />
		<p:fieldset legend="#{msgs.activityDocumentation}: #{activityDocumentationController.currentActivityToDocument.label}" toggleable="true">
			<h:form id="errorForm" rendered="#{not activityDocumentationController.activityDocumented}">
				<p:outputPanel layout="block" rendered="#{activityDocumentationController.errorParemeterNotUnique or activityDocumentationController.errorActionsMissing}" styleClass="errorMessage">
					<h:outputText rendered="#{activityDocumentationController.errorActionsMissing}" value="#{msgs.activityDocumentationMustHaveAtLeastOneAction}" />
					<h:outputText rendered="#{activityDocumentationController.errorParemeterNotUnique}" value="#{msgs.parametersMustBeUniques}" />
				</p:outputPanel>
			</h:form>
			<h:form id="infoPanelForm">
				<p:outputPanel layout="block" rendered="#{not activityDocumentationController.activityDocumented}" styleClass="infoMessage marginLogin">
					<h:outputText value="#{msgs.pleaseEnterActionsInTheOrderOfTheirExecution}"/>
				</p:outputPanel>
				<p:outputPanel layout="block" rendered="#{activityDocumentationController.activityDocumented}" styleClass="checkMessage marginLogin">
					<h:outputText value="#{msgs.activityDocumentedWithSuccess}"/>
				</p:outputPanel>
			</h:form>
			<h:form id="activityDocumentationForm">
				<p:outputPanel layout="block" rendered="#{not activityDocumentationController.activityDocumented}" styleClass="container">
					<h:panelGrid columns="3" styleClass="left width100">
						<h:outputText styleClass="bold" value="#{msgs.globalDescription}*: "/>
						<p:inputText id="inputGlobalDescription" maxlength="255" required="true" size="114" value="#{activityDocumentationController.currentActivityToDocument.globalDescription}" />
						<p:message display="icon" for="inputGlobalDescription" id="inputGlobalDescriptionMessage"/>
					</h:panelGrid>
					<h:panelGrid columns="2" styleClass="center width100">
						<p:fieldset legend="#{msgs.actions}*: " toggleable="false">
							<h:panelGrid columns="2">
								<h:outputText value="#{msgs.description}*: " />
								<p:inputText id="inputActionDescription" maxlength="255" required="true" value="#{activityDocumentationController.activityActionToCollect.description}" />
								<h:outputText value="#{msgs.result}*: " />
								<p:inputText id="inputActionResult" maxlength="255" required="true" value="#{activityDocumentationController.activityActionToCollect.result}" />
							</h:panelGrid>
							<p:commandButton action="#{activityDocumentationController.initActivityActionToCollect}" image="ui-icon ui-icon-plus" process="@this inputActionDescription inputActionResult" update="activityDocumentationForm:inputActionResult activityDocumentationForm:inputActionDescription activityDocumentationForm:actionsToAdd" value="#{msgs.add}">
								<p:collector addTo="#{activityDocumentationController.activityActionsToAdd}" value="#{activityDocumentationController.activityActionToCollect}" />
							</p:commandButton>
						</p:fieldset>
						<p:dataTable emptyMessage="#{msgs.emptyDataTableMessage}" id="actionsToAdd" paginator="false" value="#{activityDocumentationController.activityActionsToAdd}" var="action">
							<p:column styleClass="center">
								<p:commandButton image="ui-icon ui-icon-minus" process="@this" update="activityDocumentationForm:actionsToAdd">
									<p:collector removeFrom="#{activityDocumentationController.activityActionsToAdd}" value="#{action}" />
								</p:commandButton>
							</p:column>
							<p:column headerText="#{msgs.description}" sortBy="#{action.description}" styleClass="center">
								<h:outputText value="#{action.description}" />
							</p:column>
							<p:column headerText="#{msgs.result}" sortBy="#{action.result}" styleClass="center">
								<h:outputText value="#{action.result}" />
							</p:column>
						</p:dataTable>
						<p:fieldset legend="#{msgs.parameters}: " toggleable="false">
							<h:panelGrid columns="2">
								<h:outputText value="#{msgs.name}*: "/>
								<p:inputText id="inputParameterName" maxlength="30" required="true" value="#{activityDocumentationController.activityParameterToCollect.name}"/>
								<h:outputText value="#{msgs.description}*: "/>
								<p:inputText id="inputParameterDescription" maxlength="255" required="true" value="#{activityDocumentationController.activityParameterToCollect.description}"/>
							</h:panelGrid>
							<p:commandButton action="#{activityDocumentationController.initActivityParameterToCollect}" image="ui-icon ui-icon-plus" process="@this inputParameterName inputParameterDescription" update="activityDocumentationForm:inputParameterName activityDocumentationForm:inputParameterDescription activityDocumentationForm:parametersToAdd" value="#{msgs.add}">
								<p:collector addTo="#{activityDocumentationController.activityParametersToAdd}" value="#{activityDocumentationController.activityParameterToCollect}" />
							</p:commandButton>
						</p:fieldset>
						<p:dataTable emptyMessage="#{msgs.emptyDataTableMessage}" id="parametersToAdd" paginator="false" value="#{activityDocumentationController.activityParametersToAdd}" var="parameter">
							<p:column styleClass="center">
								<p:commandButton image="ui-icon ui-icon-minus" process="@this" update="activityDocumentationForm:parametersToAdd">
									<p:collector removeFrom="#{activityDocumentationController.activityParametersToAdd}" value="#{parameter}" />
								</p:commandButton>
							</p:column>
							<p:column headerText="#{msgs.name}" sortBy="#{parameter.name}" styleClass="center">
								<h:outputText value="#{parameter.name}"/>
							</p:column>
							<p:column headerText="#{msgs.description}" sortBy="#{parameter.description}" styleClass="center">
								<h:outputText value="#{parameter.description}"/>
							</p:column>
						</p:dataTable>
					</h:panelGrid>
					<p:outputPanel layout="block" styleClass="buttonContainer center">
						<p:commandButton actionListener="#{activityDocumentationController.onActivityDocumentation}" image="ui-icon ui-icon-pencil" process="@this inputGlobalDescription" update="activityDocumentationForm infoPanelForm errorForm inputGlobalDescriptionMessage" value="#{msgs.document}" />
					</p:outputPanel>
				</p:outputPanel>
			</h:form>
		</p:fieldset>
	</ui:define>
</ui:composition>